package com.lcf.system.controller;


import com.lcf.system.dto.UserAddressDTO;
import com.lcf.system.service.UserAddressService;
import com.lcf.system.vo.UserAddressVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 收货地址(UserAddress)表控制层
 *
 * @author lcf
 * @since 2025-04-24 21:14:33
 */
@Tag(name = "收货地址")
@RestController
@RequestMapping("userAddress")
public class UserAddressController {
    @Resource
    private UserAddressService userAddressService;

    /**
     * 新增
     */
    @Operation(summary = "新建")
    @PostMapping
    public boolean insert(@RequestBody @Validated UserAddressDTO dto) {
        return userAddressService.insert(dto);
    }

    /**
     * 修改
     */
    @Operation(summary = "修改")
    @PostMapping("{id}")
    public boolean update(@PathVariable @Schema(description = "收货地址id") Long id,
                          @RequestBody @Validated UserAddressDTO dto) {
        return userAddressService.update(id, dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除")
    @DeleteMapping("{id}")
    public boolean delete(@PathVariable @Schema(description = "收货地址id") Long id) {
        return userAddressService.delete(id);
    }

    /**
     * 查询
     */
    @Operation(summary = "查询")
    @GetMapping("{id}")
    public UserAddressVO query(@PathVariable @Schema(description = "收货地址id") Long id) {
        return userAddressService.query(id);
    }

    /**
     * 列表
     */
    @Operation(summary = "列表")
    @GetMapping("list")
    public List<UserAddressVO> myList() {
        return userAddressService.myList();
    }
}

